import store from "../store/index.js"

// 原聚商城小程序
 // export const apiBaseUrl = 'https://yuanju.jmkcc.net//api/'




// 测试地址 (内网穿透)
// export const apiBaseUrl = 'http://192.168.0.102:8084/'
export const apiBaseUrl = 'http://127.0.0.1:8084/'




// 需要登陆的，都写到这里，否则就是不需要登陆的接口
const generateUuid = (randomFlag, min, max) => {
	var str = '',
		range = min,
		arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
	//随机产生
	if (randomFlag) {
		range = Math.round(Math.random() * (max - min)) + min;
	}
	for (var i = 0; i < range; i++) {
		var pos = Math.round(Math.random() * (arr.length - 1));
		str += arr[pos]
	}
	return str;
}
const methodsToken = [

];

// 错误提示
function errorToast(result) {
	uni.showToast({
		title: result.throwable == null ? result.message : result.throwable,
		icon: 'none',
		duration: 1000,
		complete: function() {
			setTimeout(function() {
				uni.hideToast();
			}, 1000);
		}
	});
}




const post = (method, data, callback, hideLoading) => {
	//如果调用接口不明确指明不显示loading
	if (!hideLoading) {
		uni.showLoading({
			//title: '加载中'
		});
	}
	uni.request({
		url: apiBaseUrl + method,
		data: data,
		method: 'POST',
		header: {
			'Content-Type': 'application/json',
			'yyt-shop-token': store.state.token
		},
		success: (response) => {
			if (!hideLoading) {
				uni.hideLoading();
			}
			const result = response.data
			if (result.code == 200) {
				callback(result);
			} else if (result.code == 201) {
				if (method == "shop/follow" ||
					method == "shop/isFollowed" ||
					method == "user/getReceiveAddressList" ||
					method == "order/createOrder" ||
					method == "business/addShopCart" ||
					method == "memberSku/collect" ||
					method == "user/saveReceiveAddress" ||
					method == "subscribe/createSubscribeStore"
				) {
					errorToast({
						message: '用户未登录'
					});
					
					// 防抖
					if(uni.getStorageSync('flag')){
						uni.setStorageSync('flag', false)
						// uni.navigateTo({
						// 	url: '/pagesA/appointment/auth/authShowModel',
						// 		animationType: 'zoom-out',
						// 		animationDuration: 200,
						// })
						setTimeout(() => {
							uni.setStorageSync('flag',true)
						},12000)
					}

				}

			} else {
				errorToast(result);
			}
			// if (!result.body.status.statusCode === '0') {
			// 	// 登录信息过期或者未登录
			// 	if (result.body.status.errorCode === 'ErrorCode.common.0002' || result.body.status.errorCode ===
			// 		'ErrorCode.common.0003' || result.body.status.errorCode === 'ErrorCode.common.0004') {
			// 		uni.removeStorageSync('userToken')
			// 		uni.showToast({
			// 			title: result.body.status.errorDesc,
			// 			icon: 'none',
			// 			duration: 1000,
			// 			complete: function() {
			// 				setTimeout(function() {
			// 					uni.hideToast();
			// 					uni.navigateTo({
			// 						url: '/pages/public/login'
			// 					})
			// 				}, 1000)
			// 			}
			// 		});
			// 	}
			// }
		},
		complete: () => {
			uni.hideLoading();
		},
		fail: (error) => {
			uni.hideLoading();
			if (error && error.response) {
				showError(error.response);
			}
		},
	});

}

// 12-20 xiaoluo
const postType = (method, data, callback, hideLoading) => {
	// 请求头header信息
	var postDataHeader = {
		requestId: generateUuid(false, 32),
		timeStamp: new Date().getTime(),
		applicationId: 'b2b2c-mobile',
		ip: '0.0.0.0'
	};
	// 请求头body信息
	var postDataBody = data;
	// 判断token是否存在
	// if (methodsToken.indexOf(method) >= 0) {
	// 	// 获取用户token
	// 	let userToken = uni.getStorageSync("userToken");
	// 	if (!userToken) {
	// 		uni.navigateTo({
	// 			url:'/pages/sys/common/login'
	// 		})
	// 		return false;
	// 	} else {
	// 		//将tokenId置于请求头信息
	// 		postDataHeader.tokenId = userToken;
	// 		console.log("31223yuser,",userToken);
	// 	}
	// }
	var postData = {
		header: postDataHeader,
		body: postDataBody
	}
	//如果调用接口不明确指明不显示loading
	if (!hideLoading) {
		uni.showLoading({
			//title: '加载中'
		});
	}
	uni.request({
		url: apiBaseUrl + method,
		data: data,
		method: 'POST',
		header: {
			'Content-Type': 'application/json'
		},
		success: (response) => {
			if (!hideLoading)
				uni.hideLoading();
			const result = response.data
			// if (!result.body.status.statusCode === '0') {
			// 	// 登录信息过期或者未登录
			// 	if (result.body.status.errorCode === 'ErrorCode.common.0002' || result.body.status.errorCode ===
			// 		'ErrorCode.common.0003' || result.body.status.errorCode === 'ErrorCode.common.0004') {
			// 		uni.removeStorageSync('userToken')
			// 		uni.showToast({
			// 			title: result.body.status.errorDesc,
			// 			icon: 'none',
			// 			duration: 1000,
			// 			complete: function() {
			// 				setTimeout(function() {
			// 					uni.hideToast();
			// 					uni.navigateTo({
			// 						url: '/pages/public/login'
			// 					})
			// 				}, 1000)
			// 			}
			// 		});
			// 	}
			// }
			callback(result);
		},
		complete: () => {
			uni.hideLoading();
		},
		fail: (error) => {
			uni.hideLoading();
			if (error && error.response) {
				showError(error.response);
			}
		},
	});

}

//get
const get = (method, data, callback, hideLoading) => {

	//如果调用接口不明确指明不显示loading
	if (!hideLoading) {
		uni.showLoading({
			//title: '加载中'
		});
	}
	uni.request({
		url: apiBaseUrl + method,
		data: data,
		method: 'GET',
		header: {
			'Content-Type': 'application/json',
			'yyt-shop-token': store.state.token
		},
		success: (response) => {
			if (!hideLoading) {
				uni.hideLoading();
			}
			const result = response.data
			if (result.code == 200) {
				callback(result);
			} else if (result.code == 201) {
				if (method == "shop/follow" ||
					method == "shop/isFollowed" ||
					method == "user/getReceiveAddressList" ||
					method == "order/createOrder" ||
					method == "business/addShopCart" ||
					method == "memberSku/collect" ||
					method == "user/saveReceiveAddress" ||
					method == "subscribe/createSubscribeStore"
				) {
					errorToast({
						message: '用户未登录'
					});
					
					// 防抖
					if(uni.getStorageSync('flag')){
						uni.setStorageSync('flag', false)
						// uni.navigateTo({
						// 	url: '/pagesA/appointment/auth/authShowModel',
						// 		animationType: 'zoom-out',
						// 		animationDuration: 200,
						// })
						setTimeout(() => {							
							uni.setStorageSync('flag',true)
						},12000)
					}
				}
			} else {
				errorToast(result);
			}
		},
		complete: () => {
			uni.hideLoading();
		},
		fail: (error) => {
			uni.hideLoading();
			if (error && error.response) {
				showError(error.response);
			}
		},
	});
}
//插件post
const pluginsPost = (method, data, callback, hideLoading) => {
	uni.showLoading({
		title: '加载中'
	});

	// 判断token是否存在
	if (methodsToken.indexOf(method) >= 0) {
		// 获取用户token
		let userToken = db.get("userToken");
		if (!userToken) {
			common.jumpToLogin();
			// uni.navigateTo({
			// 	// url: '/pages/public/login'
			// 	url: '/pagesA/appointment/auth/authShowModel'
			// })
			return false;
		} else {
			data.token = userToken;
		}
	}
	uni.request({
		url: apiBaseUrl + 'plugins/' + method + '.html',
		data: data,
		header: {
			'Accept': 'application/json',
			'Content-Type': 'application/json',
			// 'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
		},
		method: 'POST',
		success: (response) => {
			uni.hideLoading();
			const result = response.data
			if (!result.status) {
				// 登录信息过期或者未登录
				if (result.data === 14007 || result.data === 14006) {
					db.del("userToken");
					uni.showToast({
						title: result.msg,
						icon: 'none',
						duration: 1000,
						complete: function() {
							setTimeout(function() {
								uni.hideToast();
								// #ifdef H5 || APP-PLUS
								uni.navigateTo({
									url: '/pages/login/login/index1'
								})
								// #endif
								// #ifdef MP-WEIXIN || MP-ALIPAY
								uni.navigateTo({
									url: '/pages/login/choose/index',
									animationType: 'pop-in',
									animationDuration: 200
								});
								// #endif
							}, 1000);
						}
					});
				}
			}
			callback(result);
		},
		fail: (error) => {
			uni.hideLoading();
			if (error && error.response) {
				showError(error.response);
			}
		},
		complete: () => {
			setTimeout(function() {
				uni.hideLoading();
			}, 250);
		}
	});

}

const showError = error => {
	let errorMsg = ''
	switch (error.status) {
		case 400:
			errorMsg = '请求参数错误'
			break
		case 401:
			errorMsg = '未授权，请登录'
			break
		case 403:
			errorMsg = '跨域拒绝访问'
			break
		case 404:
			errorMsg = `请求地址出错: ${error.config.url}`
			break
		case 408:
			errorMsg = '请求超时'
			break
		case 500:
			errorMsg = '服务器内部错误'
			break
		case 501:
			errorMsg = '服务未实现'
			break
		case 502:
			errorMsg = '网关错误'
			break
		case 503:
			errorMsg = '服务不可用'
			break
		case 504:
			errorMsg = '网关超时'
			break
		case 505:
			errorMsg = 'HTTP版本不受支持'
			break
		default:
			errorMsg = error.msg
			break
	}

	uni.showToast({
		title: errorMsg,
		icon: 'none',
		duration: 1000,
		complete: function() {
			setTimeout(function() {
				uni.hideToast();
			}, 1000);
		}
	});
}

// 文件上传
export const uploadFiles = (callback) => {
	uni.chooseImage({
		success: (chooseImageRes) => {
			uni.showLoading({
				title: '上传中...'
			});
			const tempFilePaths = chooseImageRes.tempFilePaths;
			const uploadTask = uni.uploadFile({
				url: apiBaseUrl + 'api.html', //仅为示例，非真实的接口地址
				filePath: tempFilePaths[0],
				fileType: 'image',
				name: 'file',
				headers: {
					'Accept': 'application/json',
					'Content-Type': 'multipart/form-data',
				},
				formData: {
					'method': 'images.upload',
					'upfile': tempFilePaths[0]
				},
				success: (uploadFileRes) => {
					callback(JSON.parse(uploadFileRes.data));
				},
				fail: (error) => {
					if (error && error.response) {
						showError(error.response);
					}
				},
				complete: () => {
					setTimeout(function() {
						uni.hideLoading();
					}, 250);
				}
			});
			// 					uploadTask.onProgressUpdate((res) => {
			//             console.log('上传进度' + res.progress);
			//             console.log('已经上传的数据长度' + res.totalBytesSent);
			//             console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
			//
			//             // 测试条件，取消上传任务。
			//             if (res.progress > 50) {
			//                 uploadTask.abort();
			//             }
			// 					});
		}
	});
}

// 上传图片
export const uploadImage = (num, callback) => {
	uni.chooseImage({
		count: num,
		success: (res) => {
			uni.showLoading({
				title: '上传中...'
			});
			let tempFilePaths = res.tempFilePaths
			for (var i = 0; i < tempFilePaths.length; i++) {
				uni.uploadFile({
					url: apiBaseUrl + 'uploadMediaFile',
					filePath: tempFilePaths[i],
					fileType: 'image',
					name: 'files',
					headers: {
						'Accept': 'application/json',
						'Content-Type': 'multipart/form-data',
					},
					formData: {
						'method': 'images.upload',
						'upfile': tempFilePaths[i]
					},
					success: (uploadFileRes) => {
						callback(JSON.parse(uploadFileRes.data));
					},
					fail: (error) => {
						if (error && error.response) {
							showError(error.response);
						}
					},
					complete: () => {
						setTimeout(function() {
							uni.hideLoading();
						}, 250);
					},
				});
			}
		}
	});
}

// 用户注册
// export const reg = (data, callback, hideLoading) => post('member/registerUser', data, callback, hideLoading);

// 用户名密码登录
export const doLogin = (data, callback, hideLoading) => post('member/doLogin', data, callback, true);

// 手机号登录
export const doPhoneLogin = (data, callback, hideLoading) => post('member/doPhoneLogin', data, callback, true);

// 获取验证码
export const getPhoneCode = (data, callback, hideLoading) => get('member/getPhoneCode', data, callback, true);

// 验证是否登录
export const isLogin = (data, callback, hideLoading) => get('member/isLogin', data, callback, true);

// 注销登录
export const logout = (data, callback, hideLoading) => get('member/logout', data, callback, true);


// 用户信息
export const userInfo = (data, callback, hideLoading) => get('user/getUserInfo', data, callback, true);



// 用户注册
export const register = (data, callback) => post('user/register', data, callback, true);


// 用户注册
export const getCode = (data, callback) => get('verifycode/getimage', data, callback, true);

// 找会密码
export const findPassword = (data, callback, hideLoading) => post('user/findPassword', data, callback, true);

// 首页商品列表
export const mainSkuList = (data, callback, hideLoading) => get('business/search', data, callback, hideLoading);
// 首页轮播图列表
export const swiperList = (callback) => get('mainHome/getSwiperList', {}, callback, true);
// 轮播图添加点击数
export const addSwiperCount = (data, callback) => post('mainHome/addSwiperCount', data, callback, true);
// 首页专题列表
export const subjectList = (callback) => get('mainHome/getSubjectList', {}, callback, true);
// 商品详情
export const skuDetail = (data, callback, hideLoading) => get('business/getSkuInfo', data, callback, hideLoading);
// 获取购物车商品种类数
export const getCartNum = (callback) => get('business/getShopCartNum', {}, callback, true);
// 收藏（取消收藏）商品
export const skuCollect = (data, callback) => post('memberSku/collect', data, callback, true);
// 是否已收藏商品
export const skuIsCollected = (data, callback) => get('memberSku/isCollected', data, callback, true);
// 查询用户收藏的商品列表
export const collectedSkuList = (callback) => get('memberSku/collectedList', {}, callback, true);
// 添加购物车
export const addShopCart = (data, callback) => post('business/addShopCart', data, callback, false);
// 获取店铺信息
export const getShopInfo = (data, callback, hideLoading) => get('shop/getInfo', data, callback, hideLoading);
// 获取店铺商品列表
export const getShopSkuList = (data, callback, hideLoading) => get('shop/getSkuList', data, callback, hideLoading);
// 关注（取消关注）店铺
export const followShop = (data, callback) => post('shop/follow', data, callback, false);
// 是否已关注店铺
export const isFollowShop = (data, callback) => get('shop/isFollowed', data, callback, true);
// 获取店铺公告列表
export const getNoticeList = (data, callback) => get('shop/getNoticeList', data, callback, true);
// 用户保存收货地址
export const saveMemberReceiveAddr = (data, callback) => post('user/saveReceiveAddress', data, callback, false);
// 用户删除收货地址
export const deleteMemberReceiveAddr = (data, callback) => post('user/delReceiveAddress', data, callback, false);
// 用户获取收货地址列表
export const getMemberReceiveAddrList = (callback) => get('user/getReceiveAddressList', {}, callback, false);
// 根据收货地址id获取收货地址
export const getMemberReceiveAddress = (data, callback) => get('user/getReceiveAddress', data, callback, true);
// 获取用户订单列表
export const getMemberOrderList = (data, callback) => get('order/getOrders', data, callback, true);
// 获取待付款订单和待收货订单数量
export const getMineOrderCount = (callback) => get('order/getOrderCount', {}, callback, true);
// 用户删除订单
export const deleteMemberOrder = (data, callback) => post('order/deleteOrder', data, callback, false);
// 用户确认收货
export const confirmReceiveOrder = (data, callback) => post('order/confirmReceive', data, callback, false);
// 查找的一级目录
export const catalogList = (data, callback) => get('business/catalogList', data, callback, true);
// 新的查找分类
export const getNewCatalogList = (data, callback) => get('business/getNewCatalogList', data, callback, true);
// 查找的二级目录
export const twoCatalogList = (data, callback) => get('business/twoCatalogList', data, callback, true);
// 查找的三级目录
export const threeCatalogList = (data, callback) => get('business/threeCatalogList', data, callback, true);
// 搜索
export const search = (data, callback) => get('business/search', data, callback, true);
//获取微信Id
export const getOpenid = (data, callback) => get('weixin/getOpenid', data, callback, true);
//查找该微信是否注册
export const getWxUser = (data, callback) => post('weixin/getUser', data, callback, true);
// 用户取消订单
export const memberCancelOrder = (data, callback) => post('order/cancelOrder', data, callback, false);

// 微信授权换取手机号并查询有无此账号（有则登陆）
export const getPhone = (data, callback) => get('weixin/getPhone', data, callback, true);

// 微信授权注册
export const addOpenid = (data, callback) => get('weixin/addOpenid', data, callback, true);

// 绑定手机号
export const setPhone = (data, callback) => get('weixin/setPhone', data, callback, true);


// 根据字典类型获取字典数据列表
export const getDictList = (data, callback) => get('dict/dictList', data, callback, true);

// 获取用户购物车商品
export const getShopCart = (data, callback) => get('business/getShopCart', data, callback, true);
// 修改购物车商品数量
export const setShopSize = (data, callback) => get('business/setShopSize', data, callback, true);
// 根据skuId列表获取商品详情列表
export const getSkuInfoList = (data, callback) => post('memberSku/getInfoList', data, callback, false);

// 获取用户本月订单数
export const countMonthOrder = (callback) => get('order/monthOrderNum', {}, callback, true);

// 用户下单
export const memberSubmitOrder = (data, callback, hideLoading) => post('order/createOrder', data, callback, hideLoading);
// 获取用户订单详情
export const getOrderDetailInfo = (data, callback) => get('order/getInfo', data, callback, false);
// 申请入驻
export const memberApplyJoin = (data, callback) => post('shop/applyJoin', data, callback, false);
// 获取商品评价列表
export const spuCommentList = (data, callback) => get('comment/commentPage', data, callback, false);
// 获取评价的子评论列表
export const commentSubList = (data, callback) => get('comment/getSubComments', data, callback, false);
// 根据id获取评论详情
export const commentDetailInfo = (data, callback) => get('comment/getDetailInfo', data, callback, true);
// 支付成功通知
export const payNotify = (data, callback) => get('order/payNotify', data, callback, true);
// 分页查询售后单
export const searchAfterSale = (data, callback, hideLoading) => get('consumer/searchOrderAfterSale', data, callback,
	hideLoading);
// 移除购物车
export const clearCart = (data, callback, hideLoading) => get('consumer/clearShoppingCart', data, callback,
	hideLoading);
// 删除购物车
export const deleteOnCart = (data, callback, hideLoading) => post('consumer/deleteOneCartItem', data, callback,
	hideLoading);
// 预约到店服务
export const addSubscribe = (data, callback, hideLoading) => post('subscribe/createSubscribeStore', data, callback,
	hideLoading);
// 获取当前技师信息
export const getServiceName = (data, callback, hideLoading) => get('craftsman/getServiceName', data, callback,
	hideLoading);
// 获取当前店铺技师数据
export const getCraftsmanDataAll = (data, callback, hideLoading) => get('craftsman/getCraftsmanDataAll', data, callback,
	hideLoading);
// 获取我的预约订单
export const getMyDataList = (data, callback, hideLoading) => get('subscribe/getMyDataList', data, callback,
	hideLoading);
// 订单列表跳转至
export const orderByInfoData = (data, callback, hideLoading) => get('subscribe/orderByInfoData', data, callback,
	hideLoading);
// 根据订单号获取订单类型
export const getOrderInfoType = (data, callback, hideLoading) => get('order/getOrderInfoType', data, callback,
	hideLoading);
// 获取灸大夫首页数据
export const getTypeList = (data, callback, hideLoading) => get('acupunctureType/getTypeList', data, callback,
	hideLoading);
// 查询灸大夫首页数据
export const getSearchType = (data, callback, hideLoading) => get('acupunctureType/search', data, callback,
	hideLoading);
// 查询穴位详情
export const getAcupointInfo = (data, callback, hideLoading) => get('acupunctureInfo/getAcupointInfo', data, callback,
	hideLoading);
// 查询总穴位详情
export const getFatherInfo = (data, callback, hideLoading) => get('acupunctureInfo/getFatherInfo', data, callback,
	hideLoading);
// 用户授权登录 userLoginOrAdd
export const userLoginOrAdd = (data, callback) => get('weixin/userLoginOrAdd', data, callback, true);
// 获取首页专题类型数据
export const getHomeTypeData = (data, callback) => get('homeType/getHomeTypeData', data, callback, true);
// 获取首页专题内容
export const getHomeSubjectList = (data, callback) => get('homeType/getHomeSubjectList', data, callback, true);
// 获取附近店铺
export const searchHomeShop = (data, callback) => post('home/searchHomeShop', data, callback, true);
// 未支付的订单投递到消息队列 
export const addOrderMessageQueue = (data, callback) => get('order/addOrderMessageQueue', data, callback, true);
// 获取订单倒计时  
export const getRedisCountDown = (data, callback) => get('order/getRedisCountDown', data, callback, true);
// 获取我的店铺列表
export const myShopList = (data, callback) => get('shop/myShopList', data, callback, true);
// 获取所有专题数据
export const getHomeSubject = (data, callback) => get('homeType/getHomeSubject', data, callback, true);
// 根据分类获取品牌列表 
export const getBrandList = (data, callback) => get('business/getBrandList', data, callback, true);
// 添加商品
export const addSpuInfoData = (data, callback) => post('shop/addSpuInfoData', data, callback, true);
// 获取第一级商品分类 
export const getCommodityClass = (data, callback) => get('mainHome/getCommodityClass', data, callback, true);
// 获取分类子节点
export const getChildNode = (data, callback) => get('business/getChildNode', data, callback, true);
// 外面点击进入搜索页面，第一次查询的数据
export const getClassIdBySkuInfo = (data, callback) => get('business/getClassIdBySkuInfo', data, callback, true);
// 第二层节点获取 数据
export const getChildData = (data, callback) => get('business/getChildData', data, callback, true);
// 获取购物车数量和总金额 getCartNumAndMoney
export const getCartNumAndMoney = (data, callback) => get('business/getCartNumAndMoney', data, callback, true);
// 购物车是否已经存在该条商品 
export const getSkuInfoIsNull = (data, callback) => get('business/getSkuInfoIsNull', data, callback, true);
// 购物车删除 
export const removeCartShop = (data, callback) => get('business/removeCartShop', data, callback, true);
// 获取今日订单数据统计
export const getDayCountNumber = (data, callback) => get('order/getDayCountNumber', data, callback, true);
// 获取今日订单列表 
export const getDayOrderListTitle = (data, callback) => get('order/getDayOrderListTitle', data, callback, true);
// 根据店铺id获取今日数据 
export const getShopDayOrderList = (data, callback) => get('order/getShopDayOrderList', data, callback, true);
// 根据分类父id 获取所有子节点 getChildNodeAll
export const getChildNodeAll = (data, callback) => get('business/getChildNodeAll', data, callback, true);
// 根据分类搜索商品 searchClass
export const searchClass = (data, callback) => get('business/searchClass', data, callback, true);
// 核销订单 
export const updateOrderService = (data, callback) => get('order/updateOrderService', data, callback, true);
// 根据微信id获取服务人员资格 
export const getWeChatInfo = (data, callback) => get('craftsman/getWeChatInfo', data, callback, true);
// 获取订单状态 getOrderStatus
export const getOrderStatus = (data, callback) => get('order/getOrderStatus', data, callback, true);
// 获取退款原因列表 
export const getReturnReason = (data, callback) => get('return/getReturnReason', data, callback, true);
// 申请退款
export const getReturnApplyMoney = (data, callback) => post('return/getReturnApplyMoney', data, callback, true);
// 获取个人当月订单列表 
export const getMyMonthOrder = (data, callback) => get('order/getMyMonthOrder', data, callback, true);
// 根据用户权限获取待核销订单 
export const getAwaitOrderCancel = (data, callback) => get('order/getAwaitOrderCancel', data, callback, true);
// 任务委派 
export const bindOrderServerUser = (data, callback) => get('subscribe/bindOrderServerUser', data, callback, true);
// 根据用户openId 获取管理员权限的店铺 
export const getMySysShopList = (data, callback) => get('userShop/getMySysShopList', data, callback, true);
// 变更营业状态
export const updateOnlineStatus = (data, callback) => get('shop/updateOnlineStatus', data, callback, true);
// 获取店铺营业状态 
export const getShopOnlineStatus = (data, callback, hideLoading) => get('shop/getShopOnlineStatus', data, callback, hideLoading);
// 插入分享日志
export const addShopShare = (data, callback) => post('share/addShopShare', data, callback, true);
// 获取店铺优惠券列表
export const getShopCouponList = (data, callback) => get('coupon/getShopCouponList', data, callback, true);
// 根据分享的优惠劵id 获取优惠券数据
export const getCouponById = (data, callback) => get('coupon/getCouponById', data, callback, true);
// 领取分享的优惠券
export const userGetCoupon = (data, callback) => post('coupon/userGetCoupon', data, callback, true);
// 获取我的优惠券列表
export const getMyCouponList = (data, callback) => get('coupon/getMyCouponList', data, callback, true);
// 根据优惠券id 获取可使用的商品类型
export const getSkuByIdList = (data, callback) => get('coupon/getSkuByIdList', data, callback, true);
// 根据服务获取可使用的优惠劵
export const getHistoryByUserSpuId = (data, callback) => get('history/getHistoryByUserSpuId', data, callback, true);
// 取消订单修改优惠券状态 
export const upCouponMode = (data, callback) => get('history/upCouponMode', data, callback, true);
// 获取商品结束倒计时
export const getSpuCountDown = (data, callback) => get('activity/getSpuCountDown', data, callback, true);
// 获取我的返利金额 getMyRebate
export const getMyRebate = (data, callback) => get('user/getMyRebate', data, callback, true);
// 获取用户所处的等级区间 
export const getUserEmpirical = (data, callback) => get('member/getUserEmpirical', data, callback, true);
// 获取用户积分明细 pointStatementList
export const pointStatementList = (data, callback) => get('integration/pointStatementList', data, callback, true);
// 获取年卡列表 
export const getVipList = (data, callback) => get('vip/getVipList', data, callback, true);
// 获取雪花 id
export const getSnowflakeID = (data, callback) => get('vip/getSnowflakeID', data, callback, true);
// VIP充值支付 vipTopUpPay
export const vipTopUpPay = (data, callback) => post('vip/miniAppPay', data, callback, true);
// 充值成功插入充值表 addVipMember
export const addVipMember = (data, callback) => post('vip/addVipMember', data, callback, true);
// 获取我的会员类型 getMyVipInfo
export const getMyVipInfo = (data, callback) => get('vip/getMyVipInfo', data, callback, true);
// 获取会员配送日期 
export const getDeliveryDate = (data, callback) => get('delivery/getDeliveryDate', data, callback, true);
// 获取拼团数据 
export const getGroupList = (data, callback) => get('group/getGroupList', data, callback, true);
// 获取拼团活动结束倒计时
export const getGroupCountDown = (data, callback) => get('group/getGroupCountDown', data, callback, true);
// 获取已经抢购了多少 
export const getSkuNumInfo = (data, callback) => get('group/getSkuNumInfo', data, callback, true);
// 获取拼团配送日期 
export const getGroupDeliveryDate = (data, callback) => get('group/getGroupDeliveryDate', data, callback, true);
// 获取商品全部分类
export const getCatalogList = (data, callback) => get('business/getCatalogList', data, callback, true);
// 获取我的剩余可送次数
export const getMyNumber = (data, callback) => get('vip/getMyNumber', data, callback, true);
// 配送员绑定店铺 shopBinding
export const shopBinding = (data, callback) => post('userShop/shopBinding', data, callback, true);
// 获取商户及配送员电话 
export const getShopPhone = (data, callback) => get('shop/getShopPhone', data, callback, true);
// 获取热销商品 
export const getHotSale = (data, callback) => get('home/getHotSale', data, callback, true);
// 获取秒杀商品 
export const getSeckillSku = (data, callback) => get('home/getSeckillSku', data, callback, true);
// 获取用户是否可以选菜
export const getUserIsSelect = (data, callback) => get('vip/getUserIsSelect', data, callback, true);
// 判断用户是否已经选过菜了
export const getIsPassSelect = (data, callback) => post('vip/getIsPassSelect', data, callback, true);
// 获取会员菜品 
export const getVipGreens = (data, callback) => get('vip/getVipGreens', data, callback, true);
// 判断购买商品数量是否足够 
export const isEnoughStatus = (data, callback) => post('order/isEnoughStatus', data, callback, true);
// 团购订单配送日期及是否已经团购了此商品 
export const getGroupDateBuy = (data, callback) => get('group/getGroupDateBuy', data, callback, true);
// 获取普通会员配送日期
export const getDeliveryDateList = (data, callback) => get('delivery/getDeliveryDateList', data, callback, true);
// 用户获取聊天信息 getMessageList
export const getMessageList = (data, callback) => get('message/getMessageList', data, callback, true);
// 获取用户是否已经注册 
export const getUserIsSign = (data, callback) => get('association/getUserIsSign', data, callback, true);
// 加入到协会 
export const addUserByTeam = (data, callback) => post('association/addUserByTeam', data, callback, true);
// 查询该用户是否已经绑定协会
export const getUserIsTeam = (data, callback) => get('association/getUserIsTeam', data, callback, true);
// 获取协会信息
export const getTeamInfo = (data, callback) => get('association/getTeamInfo', data, callback, true);
// 获取多商品相同优惠券 getMoreSpuCoupon
export const getMoreSpuCoupon = (data, callback) => post('memberSku/getMoreSpuCoupon', data, callback, true);
// 给用户送优惠券 
export const getUserCoupon = (data, callback) => get('history/getUserCoupon', data, callback, true);
// 获取该用户是否已经领过优惠券 
export const getMyIsCouponList = (data, callback) => get('history/getMyCouponList', data, callback, true);




















// // 获取应用全局设置
// export const applicationConfig = (data, callback, hideLoading) => post('getGlobalApplicationSetting', data, callback, hideLoading);

// // 获取参数
// export const getParameter = (data, callback, hideLoading) => post('inquiryParameter', data, callback, hideLoading);

// // 微信公众号通过code换取open id
// export const getOpenIdByCode4OfficialAccount = (data, callback, hideLoading) => post('consumer/getOpenIdByCode4OfficialAccount', data, callback, hideLoading);

// // 用户注册
// export const reg = (data, callback, hideLoading) => post('consumer/registerUser', data, callback, hideLoading);

// // 用户登录
// export const login = (data, callback, hideLoading) => post('consumer/login', data, callback, hideLoading);

// // 用户信息
// export const userInfo = (data, callback, hideLoading) => post('consumer/inquiryUser', data, callback, hideLoading);

// // 会员升级需要的会员数和销售额
// export const nextUserLevel = (data, callback, hideLoading) => post('consumer/nextUserLevelData', data, callback, hideLoading);

// // 获取邀请的会员
// export const invitedUser = (data, callback, hideLoading) => post('consumer/inquiryInvitedUsers', data, callback, hideLoading);

// // 编辑用户信息
// export const editInfo = (data, callback, hideLoading) => post('consumer/updateUserField', data, callback, hideLoading);

// // 发送短信验证码
// export const sms = (data, callback, hideLoading) => post('sendVerificationCode', data, callback, hideLoading);

// // 校验短信验证码
// export const verifyCode = (data, callback, hideLoading) => post('verifyCode', data, callback, hideLoading);

// // 重置登录密码
// export const resetPassword = (data, callback, hideLoading) => post('resetPassword', data, callback, hideLoading);

// // 修改登录密码
// export const changePassword = (data, callback, hideLoading) => post('changePassword', data, callback, hideLoading);

// // 打开消息推送
// export const enableNotification = (data, callback, hideLoading) => post('consumer/enableNotification', data, callback, hideLoading);

// // 关闭消息推送
// export const disableNotification = (data, callback, hideLoading) => post('consumer/disableNotification', data, callback, hideLoading);

// // 获取首页数据
// export const home = (data, callback, hideLoading) => post('public/home', data, callback, hideLoading);

// // 获取城市
// export const inquiryCity = (data, callback, hideLoading) => post('public/searchCity', data, callback, hideLoading);

// // 获取首页幻灯片
// export const slider = (data, callback, hideLoading) => post('inquirySwiper', data, callback, hideLoading);

// // 获取广告
// export const advert = (data, callback, hideLoading) => post('inquiryAd', data, callback, hideLoading);

// // 获取首页商品类目
// export const homeProductCate = (data, callback, hideLoading) => post('public/getHomeProductCate', data, callback, hideLoading);

// // 获取商品类目下的品牌和广告
// export const productCateAddInfo = (data, callback, hideLoading) => post('public/getProductCateAddInfo', data, callback, hideLoading);

// // 获取秒杀商品
// export const secKill = (data, callback, hideLoading) => post('public/inquirySecKill', data, callback, hideLoading);

// // 秒杀商品详情
// export const secKillDetail = (data, callback, hideLoading) => post('public/inquirySecKill', data, callback, hideLoading);

// // 获取团购商品
// export const groupBuy = (data, callback, hideLoading) => post('public/inquiryGroupBuy', data, callback, hideLoading);

// // 团购商品详情
// export const groupBuyDetail = (data, callback, hideLoading) => post('consumer/groupBuyDetail', data, callback, hideLoading);

// // 根据商品获取正在进行中的拼团
// export const getGroupBuyByProduct = (data, callback, hideLoading) => post('public/getGroupBuyByProduct', data, callback, hideLoading);

// // 抢秒杀资格
// export const seckillQuanId = (data, callback, hideLoading) => post('consumer/seckillQuanId', data, callback, hideLoading);

// // 获取首页商品组
// export const productGroup = (data, callback, hideLoading) => post('public/inquiryProductGroup', data, callback, hideLoading);

// // 获取会员注册专用商品组
// export const productGroupForRegister = (data, callback, hideLoading) => post('public/inquiryProductGroupForRegister', data, callback, hideLoading);

// // 获取商品分类
// export const productCate = (data, callback, hideLoading) => post('public/getProductCate', data, callback, hideLoading);

// // 获取文章标签
// export const inquiryTag = (data, callback, hideLoading) => post('public/inquiryTag', data, callback, hideLoading);

// // 获取文章详情
// export const articleInfo = (data, callback, hideLoading) => post('public/inquiryArticle', data, callback, hideLoading);

// // 获取文章列表
// export const articleList = (data, callback, hideLoading) => post('public/inquiryArticlePagination', data, callback, hideLoading);

// //搜索热门问题
// export const hotQaList = (data, callback, hideLoading) => post('public/inquiryHotQa', data, callback, hideLoading);

// //根据标签搜索问题
// export const qaList = (data, callback, hideLoading) => post('public/inquiryQa', data, callback, hideLoading);

// // 获取商品列表
// export const goodsList = (data, callback, hideLoading) => post('public/searchProduct', data, callback, hideLoading);

// // 获取积分商品列表
// export const pointGoodsList = (data, callback, hideLoading) => post('public/searchPointProduct', data, callback, hideLoading);

// // 获取商品详情
// export const goodsDetail = (data, callback, hideLoading) => post('public/inquiryProductDetail', data, callback, hideLoading);

// // 获取积分商品详情
// export const pointGoodsDetail = (data, callback, hideLoading) => post('public/inquiryPointProduct', data, callback, hideLoading);

// // 计算使用优惠券之后的优惠金额
// export const calculateCouponAmount = (data, callback, hideLoading) => post('consumer/calculateCouponAmount', data, callback, hideLoading);

// // 计算运费
// export const calculateFreightAmount = (data, callback, hideLoading) => post('consumer/calculateFreightAmount', data, callback, hideLoading);

// // 计算同城配送费
// export const calculateDeliveryAmount = (data, callback, hideLoading) => post('consumer/calculateDeliveryAmount', data, callback, hideLoading);

// // 计算秒杀订单运费(快递配送)
// export const calculateSecKillFreightAmount = (data, callback, hideLoading) => post('consumer/calculateSecKillFreightAmount', data, callback, hideLoading);

// // 计算秒杀订单配送费(同城配送)
// export const calculateSecKillDeliveryAmount = (data, callback, hideLoading) => post('consumer/calculateSecKillDeliveryAmount', data, callback, hideLoading);

// // 计算秒杀订单运费
// export const calculateGroupBuyFreightAmount = (data, callback, hideLoading) => post('consumer/calculateGroupBuyFreightAmount', data, callback, hideLoading);

// // 计算秒杀订单配送费(同城配送)
// export const calculateGroupBuyDeliveryAmount = (data, callback, hideLoading) => post('consumer/calculateGroupBuyDeliveryAmount', data, callback, hideLoading);

// // 计算积分订单运费
// export const calculatePointFreightAmount = (data, callback, hideLoading) => post('consumer/calculatePointFreightAmount', data, callback, hideLoading);

// // 获取商品海报
// export const goodsPoster = (data, callback, hideLoading) => post('consumer/createPoster', data, callback, hideLoading);

// // 查询收藏的商品
// export const inquiryCollectedProduct = (data, callback, hideLoading) => post('consumer/inquiryProductCollect', data, callback, hideLoading);

// // 获取商品是否已收藏
// export const isProductCollected = (data, callback, hideLoading) => post('consumer/isProductCollected', data, callback, hideLoading);

// // 收藏商品
// export const collectProduct = (data, callback, hideLoading) => post('consumer/collectProduct', data, callback, hideLoading);

// // 取消收藏商品
// export const cancelCollectProduct = (data, callback, hideLoading) => post('consumer/cancelCollectProduct', data, callback, hideLoading);

// // 评论订单
// export const commentOrder = (data, callback, hideLoading) => post('consumer/changeProductComment', data, callback, hideLoading);

// // 获取商品评论信息
// export const goodsComment = (data, callback, hideLoading) => post('public/searchProductComment', data, callback, hideLoading);

// // 添加购物车
// export const addCart = (data, callback, hideLoading) => post('consumer/addProductToCart', data, callback, hideLoading);

// // 根据购物车每条记录查询商品
// export const productByCardIds = (data, callback, hideLoading) => post('consumer/inquiryCartProductByIds', data, callback, hideLoading);

// // 移除购物车
// export const removeCart = (data, callback, hideLoading) => post('consumer/deleteProductFromShoppingCart', data, callback, hideLoading);

// // 移除购物车
// export const clearCart = (data, callback, hideLoading) => post('consumer/clearShoppingCart', data, callback, hideLoading);

// // 获取购物车列表
// export const cartList = (data, callback, hideLoading) => post('consumer/inquiryCartProduct', data, callback, hideLoading);

// // 设置购物车商品数量
// export const setCartNum = (data, callback, hideLoading) => post('consumer/updateShoppingCartProductNum', data, callback, hideLoading);

// // 获取购物车数量
// export const getCartNum = (data, callback, hideLoading) => post('consumer/getCartProductNum', data, callback, hideLoading);

// // 获取用户的收货地址列表
// export const userShip = (data, callback, hideLoading) => post('consumer/inquiryUserDeliveryAddress', data, callback, hideLoading);

// // 存储用户收货地址
// export const saveUserShip = (data, callback, hideLoading) => post('consumer/changeUserDeliveryAddress', data, callback, hideLoading);

// // 收货地址删除
// export const removeShip = (data, callback, hideLoading) => post('consumer/changeUserDeliveryAddress', data, callback, hideLoading);

// // 生成订单
// export const createOrder = (data, callback, hideLoading) => post('consumer/changeOrder', data, callback, hideLoading);

// // 生成秒杀订单
// export const createSecKillOrder = (data, callback, hideLoading) => post('consumer/addSecKillOrder', data, callback, hideLoading);

// // 生成团购订单
// export const createGroupBuyOrder = (data, callback, hideLoading) => post('consumer/addGroupBuyOrder', data, callback, hideLoading);

// // 生成积分订单
// export const createPointOrder = (data, callback, hideLoading) => post('consumer/addPointOrder', data, callback, hideLoading);

// // 取消订单
// export const cancelOrder = (data, callback, hideLoading) => post('consumer/cancelOrder', data, callback, hideLoading);

// // 删除订单
// export const delOrder = (data, callback, hideLoading) => post('consumer/changeOrder', data, callback, hideLoading);

// // 获取订单详情
// export const orderDetail = (data, callback, hideLoading) => post('consumer/inquiryOrder', data, callback, hideLoading);

// // 获取订单详情
// export const orderCourier = (data, callback, hideLoading) => post('consumer/getCourierInfo', data, callback, hideLoading);

// // 获取拆分后订单的总支付金额
// export const orderPaymentAmount = (data, callback, hideLoading) => post('consumer/inquiryPaymentAmount', data, callback, hideLoading);

// // 确认收货
// export const confirmOrder = (data, callback, hideLoading) => post('consumer/confirmOrder', data, callback, hideLoading);

// // 搜索订单
// export const searchOrder = (data, callback, hideLoading) => post('consumer/searchOrder', data, callback, hideLoading);

// // 查询订单数量
// export const searchOrderTotal = (data, callback, hideLoading) => post('consumer/searchOrderTotal', data, callback, hideLoading);

// // 搜索团购单
// export const searchGroupBuy = (data, callback, hideLoading) => post('consumer/searchGroupBuy', data, callback, hideLoading);

// // 团购单数量
// export const searchGroupBuyTotal = (data, callback, hideLoading) => post('consumer/searchGroupBuyTotal', data, callback, hideLoading);

// // 申请售后单
// export const applyAfterSale = (data, callback, hideLoading) => post('consumer/applyOrderAfterSale', data, callback, hideLoading);

// // 撤销售后单
// export const cancelAfterSale = (data, callback, hideLoading) => post('consumer/cancelOrderAfterSale', data, callback, hideLoading);

// // 更新售后单
// export const updateAfterSale = (data, callback, hideLoading) => post('consumer/updateOrderAfterSale', data, callback, hideLoading);

// // 填写售后单物流
// export const courierAfterSale = (data, callback, hideLoading) => post('consumer/courierOrderAfterSale', data, callback, hideLoading);

// // 分页查询售后单
// export const searchAfterSale = (data, callback, hideLoading) => post('consumer/searchOrderAfterSale', data, callback, hideLoading);

// // 查询售后单数量
// export const searchAfterSaleTotal = (data, callback, hideLoading) => post('consumer/searchOrderAfterSaleTotal', data, callback, hideLoading);

// // 查询系统通知
// export const inquiryNotes = (data, callback, hideLoading) => post('inquiryNotes', data, callback, hideLoading);

// // 标记系统通知为已读
// export const markNoteRead = (data, callback, hideLoading) => post('markNoteRead', data, callback, hideLoading);

// // 查询活动公告
// export const inquiryArticle = (data, callback, hideLoading) => post('public/inquiryArticle', data, callback, hideLoading);

// // 售后单详情
// export const afterSalesInfo = (data, callback, hideLoading) => post('consumer/inquiryOrderAfterSaleDetail', data, callback, hideLoading);

// // 小程序微信支付接口
// export const wechatPay = (data, callback, hideLoading) => post('consumer/initWechatPay', data, callback, hideLoading);

// // 公众号微信支付接口
// export const wechatPayH5 = (data, callback, hideLoading) => post('consumer/initWechatPayH5', data, callback, hideLoading);

// // APP微信支付接口
// export const wechatPayApp = (data, callback, hideLoading) => post('consumer/initWechatPayApp', data, callback, hideLoading);

// // 获取微信支付签名
// export const getSignature = (data, callback, hideLoading) => post('consumer/getSignature', data, callback, hideLoading);

// // 支付宝H5端接口
// export const alipay = (data, callback, hideLoading) => post('consumer/initAlipay', data, callback, hideLoading);

// // 支付宝APP端接口
// export const alipayApp = (data, callback, hideLoading) => post('consumer/initAlipayApp', data, callback, hideLoading);

// // 模拟支付成功接口
// export const balancePay = (data, callback, hideLoading) => post('consumer/balancePay', data, callback, hideLoading);

// // 优惠券列表
// export const couponList = (data, callback, hideLoading) => post('public/searchCoupon', data, callback, hideLoading);

// // 用户领取优惠券
// export const getCoupon = (data, callback, hideLoading) => post('consumer/changeCoupon', data, callback, hideLoading);

// // 用户已领取的优惠券列表
// export const userCoupon = (data, callback, hideLoading) => post('consumer/searchUserCoupon', data, callback, hideLoading);

// // 订单电子卡券
// export const voucherList = (data, callback, hideLoading) => post('consumer/inquiryVoucher', data, callback, hideLoading);

// // 获取用户奖金明细
// export const getBalanceList = (data, callback, hideLoading) => post('consumer/searchUserAward', data, callback, hideLoading);

// // 获取用户余额明细
// export const getStatementList = (data, callback, hideLoading) => post('consumer/searchUserStatement', data, callback, hideLoading);

// // 获取团队业绩明细
// export const getPerformanceList = (data, callback, hideLoading) => post('consumer/searchUserPerformance', data, callback, hideLoading);

// // 用户提现
// export const userToCash = (data, callback, hideLoading) => post('consumer/applyWithdraw', data, callback, hideLoading);

// // 用户提现列表
// export const cashList = (data, callback, hideLoading) => post('consumer/searchUserWithdraw', data, callback, hideLoading);

// // 查询提现详情
// export const withdrawDetail = (data, callback, hideLoading) => post('consumer/inquiryUserWithdraw', data, callback, hideLoading);

// // 查询商家
// export const merchantList = (data, callback, hideLoading) => post('public/searchMerchant', data, callback, hideLoading);

// // 查询商家优惠券
// export const merchantCouponList = (data, callback, hideLoading) => post('public/searchMerchantCoupon', data, callback, hideLoading);

// // 商家列表
// export const nearbyMerchant = (data, callback, hideLoading) => post('consumer/inquiryNearMerchant', data, callback, hideLoading);

// // 商家详情
// export const merchantDetail = (data, callback, hideLoading) => post('public/inquiryMerchant', data, callback, hideLoading);

// // 查询是否关注商家
// export const isMerchantFollowed = (data, callback, hideLoading) => post('consumer/isMerchantFollowed', data, callback, hideLoading);

// // 关注商家
// export const followMerchant = (data, callback, hideLoading) => post('consumer/followMerchant', data, callback, hideLoading);

// // 查询关注的商家
// export const followedMerchant = (data, callback, hideLoading) => post('consumer/inquiryFollowedMerchant', data, callback, hideLoading);

// // 取消关注商家
// export const cancelFollowMerchant = (data, callback, hideLoading) => post('consumer/cancelFollowMerchant', data, callback, hideLoading);

// // 微信订阅消息
// export const wxSuscribeMsg = (data, callback, hideLoading) => post('public/inquirySuscribeMsg', data, callback, hideLoading);

// //查询新人福利
// export const inquiryProfitWelfare = (data, callback, hideLoading) => post('consumer/inquiryProfitWelfare', data, callback, hideLoading);

// //领取新人福利
// export const receiveProfitWelfare = (data, callback, hideLoading) => post('consumer/receiveProfitWelfare', data, callback, hideLoading);

// //获取积分签到设置
// export const signSetting = (data, callback, hideLoading) => post('public/getSignSetting', data, callback, hideLoading);

// //是否签到
// export const isPointSigned = (data, callback, hideLoading) => post('consumer/isPointSigned', data, callback, hideLoading);

// //连续签到天数
// export const signDateNum = (data, callback, hideLoading) => post('consumer/getSignDateNum', data, callback, hideLoading);

// //积分签到
// export const signPoint = (data, callback, hideLoading) => post('consumer/signPoint', data, callback, hideLoading);

// //积分明细
// export const pointStatementList = (data, callback, hideLoading) => post('consumer/searchUserPointStatement', data, callback, hideLoading);

// //直播间列表
// export const wechatLiveRoomList = (data, callback, hideLoading) => post('public/inquiryWechatLiveRooms', data, callback, hideLoading);
